<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>backdrop方案</title>
    <style>
        dialog::backdrop {
            background: rgba(0, 0, 0, 0.8);
        }
    </style>
</head>
<body>
<button onclick="showDialog()">打开弹窗</button>
<button onclick="goback()">返回原页面</button>
<dialog>
    这是内容
    <button onclick="hideDialog()">关闭</button>
</dialog>
<script>
    function showDialog() {
        console.log(1);
        const dialog = document.querySelector('dialog');
        dialog.showModal();
    }

    function hideDialog() {
        const dialog = document.querySelector('dialog');
        dialog.close();
    }

    function goback() {
        history.back();
    }
</script>
</body>
</html>
